<?php

require_once("../conexion/conexion.php");

$CodExp = $_GET['CodExp'];
$OpcElim = $_GET['OpcElim'];
$IdEli = $_GET['IdEli'];
$pPerCodigo = "";

    $sql = " SELECT PER_CODIGO FROM PERSONAS_CON_DISCAPACIDAD WHERE EXP_CODIGO = '$CodExp'";
        $result = mysql_query($sql);
        while ($row=mysql_fetch_array($result))
	{
            $pPerCodigo = $row["PER_CODIGO"];
        }
        mysql_free_result($result);
    
        if ($OpcElim == 1)
        {
            $sql = "DELETE FROM DISCAPACIDAD_PERSONA WHERE DIP_CODIGO = $IdEli AND PER_CODIGO = $pPerCodigo";
            $result = mysql_query($sql);
            if (!$result) 
                {
                    die ("Invalido: " . mysql_error());
                }
            else
                {
                    echo "OK";
                }
        }
        elseif ($OpcElim == 2)
        {
            $sql = "DELETE FROM FORMACION_REALIZADA WHERE FOR_CODIGO = $IdEli AND EXP_CODIGO = '$CodExp'";
            $result = mysql_query($sql);
            if (!$result) 
                {
                    die ("Invalido: " . mysql_error());
                }
            else
                {
                    echo "OK";
                }
        }
        elseif ($OpcElim == 3)
        {
            $sql = "DELETE FROM INTERES WHERE INT_CODIGO = $IdEli AND EXP_CODIGO = '$CodExp'";
            $result = mysql_query($sql);
            if (!$result) 
                {
                    die ("Invalido: " . mysql_error());
                }
            else
                {
                    echo "OK";
                }
        }
        elseif ($OpcElim == 4)
        {
            $sql = "DELETE FROM FORMACION_IDIOMA WHERE FOI_CODIGO = $IdEli AND EXP_CODIGO = '$CodExp'";
            $result = mysql_query($sql);
            if (!$result) 
                {
                    die ("Invalido: " . mysql_error());
                }
            else
                {
                    echo "OK";
                }
        }
        elseif ($OpcElim == 5)
        {
            $sql = "DELETE FROM FORMACION_INFORMATICA WHERE FIN_CODIGO = $IdEli AND EXP_CODIGO = '$CodExp'";
            $result = mysql_query($sql);
            if (!$result) 
                {
                    die ("Invalido: " . mysql_error());
                }
            else
                {
                    echo "OK";
                }
        }
        elseif ($OpcElim == 6)
        {
            $sql = "DELETE FROM EXPERIENCIA_LABORAL WHERE EXL_CODIGO = $IdEli AND EXP_CODIGO = '$CodExp'";
            $result = mysql_query($sql);
            if (!$result) 
                {
                    die ("Invalido: " . mysql_error());
                }
            else
                {
                    echo "OK";
                }
        }
?>
